package org.eztouch.sys.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.eztouch.sys.entity.SysDic;
import org.eztouch.sys.facade.SysDicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/sysDic")
public class SysDicController {
	@Autowired
	private SysDicService sysDicService;
	
	@RequestMapping("/add")
	public String add(){
		SysDic dic = new SysDic();
		dic.setCreateBy(1L);
		dic.setCreateTime(new Date());
		dic.setDicKey("cs-key");
		dic.setDicType("cs");
//		dic.setDicValue("cs-value");
		
		sysDicService.insert(dic);
		return "添加成功";
	}
	
	@RequestMapping("/get")
	public Object get(){
		List<SysDic> list = sysDicService.selectByType("cs");
		return list;
	}
	
	@RequestMapping("/getByValue")
	public Object getByValue(){
		SysDic dic = sysDicService.selectByTypeAndKey("11update", "");
		return dic;
	}
	
	@RequestMapping("/update")
	public Object update(){
		sysDicService.update(874529076687319040L);
		return "更新成功！";
	}
	
	@RequestMapping("/getByIds")
	public Object getByIds(){
		List<Long> ids = new ArrayList<Long>();
		ids.add(-1L);
		ids.add(874529076687319040L);
		ids.add(874529091048615936L);
		List<SysDic> dics = sysDicService.selectByListIds(ids);
		return dics;
	}
}
